<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../lib/pcyangshi.css">
    <style>
        .login{
            width: 400px;
            height: 400px; 
            background: #fff;
            margin: 100px auto;
            padding: 10px;
            border: 2px solid #ff8000;
        }
        h2{
            text-align: center;
            border-bottom: 1px solid #ff8000;
            padding-bottom: 10px;
            color: #ff8000;
        }
        #inp,#inp2{
            outline: none;
            border: 1px solid #ccc;
            display: block;
            margin: 26px auto;
            width: 300px;
            height: 40px;
            padding: 10px;
            box-sizing: border-box;
            font-size: 16px;
            text-indent: 6px;
        }
        [type="button"]{
            width: 50px;
            height: 30px;
        }
        #login{
            width: 300px;
            height: 40px;
            background: #ff8000;
            border: none;
            margin: 30px 0 0 50px;
            font-size: 20px;
            font-weight: bold;
            color: white;
            cursor:pointer;
        }
        a{
            display: block;
            width: 300px;
            height: 40px;
            background: #ff8000;
            text-align: center;
            line-height: 40px;
            font-size: 20px;
            font-weight: bold;
            margin: 30px auto;
            color: white;
        }
        [type="checkbox"]{
            margin-left: 50px;
            margin-right: 6px;
        }
    </style>
</head>
<body>
    <form class="login">
        <h2>账户登录</h2>
        <input type="text" id="inp" placeholder="请输入用户名">
        <input type="password" id="inp2" placeholder="请输入密码">
        <input type="checkbox" id="day" >七天免登陆<br/>
        <input type="button" value="登录" id='login'>
        <a href="http://localhost/suning/src/pages/zhuce.HTML">注册</a>
    </form>
    <script src="../lib/jquery-1.12.4.min.js"></script> -->
    <script>
        var day = document.querySelector('#day');
        
        $('#login').on('click',function(){
            var inpName = $('#inp').val();
            var inpPassword = $('#inp2').val();
            console.log($('#day')[0].checked);
            if($('#day')[0].checked){
                var day = 1;
            }else{
                var day = 0;
            }
            $.ajax({
                url:"http://localhost/suning/src/interface/01.php", // 请求地址，必填
                type:"POST", // 请求方式(GET,POST,..)默认是GET
                data:{
                    un:inpName,
                    pw:inpPassword,
                    day:day
                }, // 携带到后端的参数
                dataType:"json", 
                success:function(res){
                    if(res){
                        alert('登录成功点击确定跳往主页');
                        location.href = 'http://localhost/suning/src/pages/suningindex.html'
                    }else{
                        alert('用户名或密码错误')
                    }
                }, // 成功的回调
            })
        })

    </script>
</body>
</html>